import request from '@/utils/request'

// ==================== 试卷管理 API ====================

// 查询试卷列表
export function listExamPaper(query) {
  return request({
    url: '/module/exam/paper/list',
    method: 'get',
    params: query
  })
}

// 查询试卷详细
export function getExamPaper(id) {
  return request({
    url: '/module/exam/paper/' + id,
    method: 'get'
  })
}

// 新增试卷
export function addExamPaper(data) {
  return request({
    url: '/module/exam/paper',
    method: 'post',
    data: data
  })
}

// 修改试卷
export function updateExamPaper(data) {
  return request({
    url: '/module/exam/paper',
    method: 'put',
    data: data
  })
}

// 删除试卷
export function delExamPaper(ids) {
  return request({
    url: '/module/exam/paper/' + ids,
    method: 'delete'
  })
}

// 导入试卷JSON文件
export function importExamPaper(formData) {
  return request({
    url: '/module/exam/paper/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    timeout: 120000  // 导入可能需要较长时间，设置2分钟超时
  })
}

// 租户前台：随机获取试题
export function getRandomQuestions(paperId) {
  return request({
    url: '/module/exam/paper/' + paperId + '/random',
    method: 'get'
  })
}

